<template>
	<view class="pb40">
		<view class="register mb24">
			<Title :txt="i18n.shangc+coin+i18n.pingz" :showback="true"></Title>
		</view>
		<text class="moneyname f14 mt5 white">{{coin}} {{i18n.sl}}</text>
		<view class="moneybox pd15 mt9 fsc">
			<view class="wp100"><input class="f15 wp100" type="number" v-model="number"  value="" :placeholder="i18n.srczsl" /></view>
		</view>
		<view class="moneyname mt15 f14 white">{{i18n.zcqb}}</view>
		<view class="moneybox pd15 mgt20 fsc">
			<view class="wp100"><input class="f15 wp100" type="text" :placeholder="i18n.srzcqb" v-model="address" /></view>
		</view>
		<view class="moneyname white mt15 f14">{{i18n.jyhs}}</view>
		<view class="moneybox pd15 mgt20 fsc">
			<view class="wp100"><input class="f15 wp100" type="text" value="" v-model="hash" :placeholder="i18n.qsrhx" /></view>
		</view>
		<view class="text--center">
			<image :src="pic" class="addicon"  @click="upImage"></image>
			<view class="sgrey f14 mt8">{{i18n.shangc}} {{coin}}{{i18n.fkpz}}</view>
		</view>
		<view class="okextract mgt20" @click="uploadVerti">{{i18n.scpz}}</view>
	</view>
</template>

<script>
	import uploadFile from '@/mixins/uploadFile'
export default {
	mixins: [uploadFile],
	data() {
		return {
			number:'',
			address:'',
			hash:'',
			upimage:'',
			coin:'',
			pic:'../../static/uesr/add.png',
			
		};
	},
	onLoad(op) {
		this.coin = op.coin
	},
	onShow() {
	},
	computed:{
		i18n() {
			return this.$t('ecology');
		}
	},
	methods: {
		async upImage(){
			console.log(2)
				let [err, res] = await uni.chooseImage({
					count: 1,
					sizeType: ['compressed'],
					sourceType: ['album', 'camera']
				})
				if (res) {
					this.pic = res.tempFilePaths[0]
					this.upload()
				}
		},
		async upload() {
			let img = await this.uploadFile([this.pic])
			console.log(img)
			this.upimage = img
		},
		selectcharge(index) {
			// console.log(index);
			this.index = index;
		},
		bindPickerChange: function(e) {
			console.log('picker发送选择改变，携带值为', e.target.value);
			this.index1 =e.target.value;
			this.number=""
			this.getMoney()
		},
		uploadVerti() {
			if(this.number <= 0 ){
				uni.showToast({
					title:this.$t('ecology').srczsl,
					icon: "none",
				})
				return false;
			}
			if(this.address == ''){
				uni.showToast({
					title:this.$t('ecology').srzcqb,
					icon: "none",
				})
				return false;
			}
			if(this.hash == ''){
				uni.showToast({
					title:this.$t('ecology').qsrhx,
					icon: "none",
				})
				return false;
			}
			if(this.upimage == ''){
				uni.showToast({
					title:this.$t('ecology').qscfkpz,
					icon: "none",
				})
				return false;
			}
			let params = {
				coin:this.coin,
				fromAddress:this.address,
				money:this.number,
				txHash:this.hash,
				image:this.upimage
			};
			this.$http.post('wallet.upLog', params).then(res => {
				console.log(res);
				if (res.code == 200) {
					uni.showToast({
						title:this.$t('ecology').sccgsh,
						icon: "none",
					})
					this.number = ''
					this.hash = ''
					this.upimage = ''
					this.address = ''
				}
			});
		},
		scanCode() {
			let that = this;
			uni.scanCode({
				success: function(res) {
					// console.log(res);
					that.address = res.result;
				}
			});
		}
	}
};
</script>

<style lang="less">
	.addicon{
		width: 214rpx;
		height: 214rpx;
		display: block;
		margin:36rpx auto 0;
	}
	.textcolor{
		color:#586471;
	}
	.fw0{
		font-weight: 0 !important;
	}
	.buttonable {
		width: 180rpx;
		height: 56rpx;
		line-height: 56rpx;
		text-align: center;
		opacity: 1;
		background: #1372df;
		border-radius: 6rpx;
		color: #fff;
	}
	.buttondisable {
		width: 180rpx;
		height: 56rpx;
		line-height: 56rpx;
		text-align: center;
		opacity: 1;
		background: #efefef;
		border-radius: 6rpx;
		color: #6d7278;
	}
.popupcontent {
	font-size: 28rpx;
	line-height: 44rpx;
	overflow-y: scroll;
	height: 600rpx;
	text-align: left;
	padding: 30rpx;
	width: 690rpx;
	display: block;
}
.itembox {
	width: 690rpx;
	padding: 0 0rpx 36rpx 0rpx;
	border-bottom: 2rpx solid #ccc;
	margin-left: auto;
	margin-right: auto;
	
	input {
		text-align: right;
	}
}
page {
	padding-bottom: 80rpx;
}
.register {
	.back {
		justify-content: center;
		align-items: center;
		display: flex;
		font-size: 34rpx;
		margin-left: 30rpx;
		position: relative;
		.leftarrow {
			position: absolute;
			left: 0;
			top: 0;
			width: 32rpx;
			height: 32rpx;
		}
	}
	.chrecord {
		position: absolute;
		top: 4rpx;
		right: 0;
		margin-right: 30rpx;
		color:#586471;
	}
}
.moneyname {
	padding-left: 30rpx;
}
.moneybox {
	width: 630rpx;
	height: 45rpx;
	opacity: 1;
	background: #121d2c;
	border-radius: 16rpx;
	margin-left: auto;
	margin-right: auto;
	image {
		width: 36rpx;
		height: 36rpx;
	}
}
.okextract {
	width: 690rpx;
	height: 88rpx;
	line-height: 88rpx;
	opacity: 1;
	background: #1372df;
	border-radius: 8rpx;
	color: #fff;
	text-align: center;
	font-size: 32rpx;
	margin-left: auto;
	margin-right: auto;
}
// .uni-picker-container{
// 	color: #828282;
// 	font-size: 24rpx;
// }
</style>
